<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2015-11-2
 * Time: 17:22
 */
require_once 'C:\xampp\htdocs\laravel\PHPExcel.php';

try {
    $inputFileName = 'test.xlsx';
    $objPHPExcel = PHPExcel_IOFactory::load($inputFileName);
    $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, "Excel2007");
    //PHPExcel_Cell::setValueBinder( new PHPExcel_Cell_AdvancedValueBinder() );

    $objWorksheet = $objPHPExcel->getActiveSheet();
    $objWorksheet->setCellValue('A4', '王德明');
    $objWorksheet->setCellValue('B4', 40);
    $objWorksheet->setCellValue('C4', 756.5);
    $date = gmmktime(0,0,0,12,31,2015);
    $excelDateValue = PHPExcel_Shared_Date::PHPToExcel( $date );
    $objWorksheet->setCellValue('D4', $excelDateValue);
    /*$objPHPExcel->getActiveSheet()->getStyle('D4')
        ->getNumberFormat()
        ->setFormatCode(
            PHPExcel_Style_NumberFormat::FORMAT_DATE_YYYYMMDDSLASH
        );*/
    $time=gmmktime(9,46,55,null,null,null);
    $excelTimeValue=PHPExcel_Shared_Date::PHPToExcel($time);
    $objWorksheet->setCellValue('E4', $excelTimeValue);
    $objWriter->save($inputFileName);
    echo 'sucessfully!';
} catch (Exception $e) {
    echo 'Failed:'.$e->getMessage();
}